#ifndef __TOTEM_LRC
#define __TOTEM_LRC

#include <glib.h>
#include <gtk/gtk.h>

#include "lmp-debug.h"

#include <glib/gstdio.h>

#define TOTEM_TYPE_LRC_PLUGIN		(totem_lrc_plugin_get_type ())
#define TOTEM_LRC_PLUGIN(o)			(G_TYPE_CHECK_INSTANCE_CAST ((o), TOTEM_TYPE_LRC_PLUGIN, TotemLrcPlugin))
#define TOTEM_LRC_PLUGIN_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), TOTEM_TYPE_LRC_PLUGIN, TotemLrcPluginClass))
#define TOTEM_IS_LRC_PLUGIN(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), TOTEM_TYPE_LRC_PLUGIN))
#define TOTEM_IS_LRC_PLUGIN_CLASS(k)		(G_TYPE_CHECK_CLASS_TYPE ((k), TOTEM_TYPE_LRC_PLUGIN))
#define TOTEM_LRC_PLUGIN_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), TOTEM_TYPE_LRC_PLUGIN, TotemLrcPluginClass))

typedef enum {
	TASK_NOTHING,
	TASK_DOING,
	TASK_DOWNLOAD_OK,		/// lyric is downloaded
	TASK_GO_DOWNLOAD,		/// call download function
	TASK_READY_DOWNLOAD,	/// lyric is find it ready to  download
	TASK_DOWNLOAD_FAIL,		/// can't download lyrics
	TASK_SEARCH_AUTO,
	TASK_SEARCH_MANUAL,
	TASK_SEARCH_OK,			/// lyric finded and will download the first one
	TASK_GO_SEARCH,			/// go to search lyric and tell ready when find lyric
	TASK_SEARCH_FAIL,		/// can't find lyric
	TASK_JOB_LIST
}TaskType;


typedef struct {
	gchar *path ;
	gchar *title ;
	gchar *artist ;
	GSList* (*get_lyric_list)(gchar *artist,gchar *title,...);
	gchar *lyricfile_r;
	///if can't find lyirc ,lyricfile_r is NULL;
	gchar *lyricfile_w;
	///if lyricfile_r != NULL && lyricfile_r can be write,
	///then lyricfile_r == lyricfile_w;
	GSList *list;
	gchar *url;
	///url should not be free for it pointer to 
	///list->data->url,it will be free when free list
	///we don't need double free crach
}MataInfo;

typedef struct
{
	TotemPlugin   parent;
	Totem *totem;
	GtkWindow *win;
	GtkStatusIcon *status;
	GtkWidget *pad;
	MataInfo *minfo;
	GKeyFile *conf;
	gchar **default_code;
	FILE *filew;
	gulong open_id;
	gulong close_id;
	gulong mata_id;
	gulong timeout_id;
	TaskType tsk;
}TotemLrcPlugin;

typedef struct
{
	TotemPluginClass parent_class;
	void (*lrc_evt_id)(TotemLrcPlugin *plugin,char evt_id);
}TotemLrcPluginClass;

typedef struct
{
	TotemLrcPlugin *pi;
	GtkWidget *widget;
}ConfigData;

G_MODULE_EXPORT GType register_totem_plugin	(GTypeModule *module);
GType	totem_lrc_plugin_get_type		(void) G_GNUC_CONST;

extern const gchar *def_code[];


enum {
	PLUGIN_NAME = 0,
	PLUGIN_LRC_PATHS,
	PLUGIN_WIN_MODEL,
	PLUGIN_SIDE_BAR,
	PLUGIN_ENGINEER,
	PLUGIN_LAST_KEYS
};

void totem_lrc_plugin_send_event(TotemLrcPlugin *pi,gint id);

GtkWidget * dialog_config(TotemPlugin *plugin);

GtkWindow *totem_lrc_plugin_get_win(TotemLrcPlugin *pi);
void totem_lrc_plugin_set_artist_title(TotemLrcPlugin *plugin);

#undef _
#define _(a) a
#endif //__TOTEM_LRC
